<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>数组</title>
</head>

<body>
    <p>数组：一组数据的集合，数组的每一个数据叫做元素。</p>
    <p>注：数组中的元素可以是任意类型的数据，包括字符串，数字，集合，对象等。</p>
    <p style="color: red;">注：每个数组都有一个 Length(长度)属性。</p>
    <p style="color: red;">注：数组是一个特殊的对象，qi3类型为 object</p>
    <p>数组的创建方式：</p>
    <script>
        document.write("创建方式一：隐式方式创建数组：", "<br>");
        var arr1 = ["张三", "李四", "王五", "赵六"];
        var arr2 = [1, 2, 3, 4, 5];
        var arr3 = [1, "张三", true, arr2, {}];
        document.write('var arr1 = ["张三","李四","王五","赵六"];', "<br>");
        document.write('var arr2 = [1,2,3,4,5]', "<br>");
        document.write('var arr3 = [1,"张三",true,arr2,{}]', "<br>");
        console.log(arr3);
        console.log("数组的类型：", typeof arr1);

        document.write("创建方式二：直接实例化，通过构造函数Array()创建数组：", "<br>");
        var arr4 = new Array("张三", "李四", "王五", "赵六");
        var arr5 = new Array(2); //此处设置了数组的长度为2，但是数组的长度是可以随时改变的，可以进行更多的添加元素。
        arr5[0] = "张三";
        arr5[1] = "李四";
        arr5[2] = "王五";
        arr5[3] = "赵六";
        document.write('var arr4 = new Array("张三","李四","王五","赵六");', "<br>");
    </script>
</body>

</html>